﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NUnit.Framework;

//
// UtilityClasses.cs
//
// Contains miscellaneous utility classes for our models
//

namespace SetListManager.Models
{
        /// <summary>
        /// The MinSec class keeps track of durations in minutes and seconds.
        /// </summary>

        public class MinSec
        {
            public int Minutes { get; set; }
            public int Seconds { get; set; }

            public MinSec(int min, int sec)
            {
                if (sec > 60)
                {
                    // They specified only seconds, we need to calculate minutes
                    this.Minutes = min + sec / 60;
                    this.Seconds = sec % 60;
                }
                else
                {

                    this.Minutes = min;
                    this.Seconds = sec;
                }
            }
            public MinSec()
            {

            }


            /// <summary>
            /// Returns the song duration in a string formatted "minutes:seconds".
            /// </summary>
            public string FormatMinSec
            {
                get
                {
                    return string.Format("{0:d}:{1:d2}", Minutes, Seconds);
                }
            }
            /// <summary>
            /// Returns the song duration in a string formatted "[hours] hrs [minutes] min".
            /// </summary>
            public string FormatHrsMin
            {
                get
                {
                    int hrs = Minutes / 60;
                    int min = Minutes % 60;

                    return string.Format("{0:d} hrs {1:d} min", hrs, min);
                }
            }

            /// <summary>
            /// Returns the total number of seconds this object represents
            /// </summary>
            /// <returns></returns>
            public string FormatSeconds
            {
                get {
                    return string.Format("{0:d}", (Minutes * 60) + Seconds);
                }
            }

        }

        /// <summary>
        /// UsageTypes stores possible values for the "Usage" field in our Song class
        /// </summary>
        public class UsageType
        {
            /// <summary>
            /// Primary key
            /// </summary>
            public int UsageTypeID { get; set; }

            /// <summary>
            /// Foreign key to the Band that is associated with this record.  Each band can have their
            /// own collection of UsageTypes.
            /// </summary>
            public int BandID { get; set; }

            /// <summary>
            /// Text denoting what kind of usagetype this is
            /// </summary>
            public string UsageText { get; set; }
        }



        /// <summary>
        /// Class that encapsulates most common parameters sent by DataTables plugin
        /// </summary>
        public class jQueryDataTableParamModel
        {
            /// <summary>
            /// Request sequence number sent by DataTable,
            /// same value must be returned in response
            /// </summary>       
            public string sEcho { get; set; }

            /// <summary>
            /// Text used for filtering
            /// </summary>
            public string sSearch { get; set; }

            /// <summary>
            /// Number of records that should be shown in table
            /// </summary>
            public int iDisplayLength { get; set; }

            /// <summary>
            /// First record that should be shown(used for paging)
            /// </summary>
            public int iDisplayStart { get; set; }

            /// <summary>
            /// Number of columns in table
            /// </summary>
            public int iColumns { get; set; }

            /// <summary>
            /// Number of columns that are used in sorting
            /// </summary>
            public int iSortingCols { get; set; }

            /// <summary>
            /// Comma separated list of column names
            /// </summary>
            public string sColumns { get; set; }
        }


}